home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cc / sprite / RCS / toplev.c,v < prev    next >
Encoding:
Text File  |  1990-08-21  |  52.6 KB  |  2,113 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.08.21.00.17.39;  author rab;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.08.20.15.46.42;  author rab;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Don't print a warning if `rcsid' is unused.
  27. @
  28. text
  29. @/* Top level of GNU C compiler
  30.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  31.  
  32. This file is part of GNU CC.
  33.  
  34. GNU CC is free software; you can redistribute it and/or modify
  35. it under the terms of the GNU General Public License as published by
  36. the Free Software Foundation; either version 1, or (at your option)
  37. any later version.
  38.  
  39. GNU CC is distributed in the hope that it will be useful,
  40. but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42. GNU General Public License for more details.
  43.  
  44. You should have received a copy of the GNU General Public License
  45. along with GNU CC; see the file COPYING.  If not, write to
  46. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  47.  
  48.  
  49. /* This is the top level of cc1.
  50.    It parses command args, opens files, invokes the various passes
  51.    in the proper order, and counts the time used by each.
  52.    Error messages and low-level interface to malloc also handled here.  */
  53.  
  54. #include "config.h"
  55. #include <stdio.h>
  56. #include <signal.h>
  57. #include <setjmp.h>
  58.  
  59. #include <sys/types.h>
  60. #include <sys/stat.h>
  61.  
  62. #ifdef USG
  63. #undef FLOAT
  64. #include <sys/param.h>
  65. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  66. #undef FLOAT
  67. #include <sys/times.h>
  68. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  69. #undef FFS  /* Some systems define this in param.h.  */
  70. #else
  71. #ifndef VMS
  72. #include <sys/time.h>
  73. #include <sys/resource.h>
  74. #endif
  75. #endif
  76.  
  77. #include "input.h"
  78. #include "tree.h"
  79. #include "c-tree.h"
  80. #include "rtl.h"
  81. #include "flags.h"
  82.  
  83. extern int yydebug;
  84.  
  85. extern FILE *finput;
  86.  
  87. extern int reload_completed;
  88. extern int rtx_equal_function_value_matters;
  89.  
  90. extern void init_lex ();
  91. extern void init_decl_processing ();
  92. extern void init_tree ();
  93. extern void init_rtl ();
  94. extern void init_optabs ();
  95. extern void init_reg_sets ();
  96. extern void dump_flow_info ();
  97. extern void dump_local_alloc ();
  98.  
  99. void rest_of_decl_compilation ();
  100. void error ();
  101. void error_with_file_and_line ();
  102. void fancy_abort ();
  103. void set_target_switch ();
  104. void print_target_switch_defaults ();
  105.  
  106. /* Bit flags that specify the machine subtype we are compiling for.
  107.    Bits are tested using macros TARGET_... defined in the tm-...h file
  108.    and set by `-m...' switches.  */
  109.  
  110. int target_flags;
  111.  
  112. /* Name of current original source file (what was input to cpp).
  113.    This comes from each #-command in the actual input.  */
  114.  
  115. char *input_filename;
  116.  
  117. /* Name of top-level original source file (what was input to cpp).
  118.    This comes from the #-command at the beginning of the actual input.
  119.    If there isn't any there, then this is the cc1 input file name.  */
  120.  
  121. char *main_input_filename;
  122.  
  123. /* Current line number in real source file.  */
  124.  
  125. int lineno;
  126.  
  127. /* Stack of currently pending input files.  */
  128.  
  129. struct file_stack *input_file_stack;
  130.  
  131. /* Incremented on each change to input_file_stack.  */
  132. int input_file_stack_tick;
  133.  
  134. /* FUNCTION_DECL for function now being parsed or compiled.  */
  135.  
  136. extern tree current_function_decl;
  137.  
  138. /* Name to use as base of names for dump output files.  */
  139.  
  140. char *dump_base_name;
  141.  
  142. /* Flags saying which kinds of debugging dump have been requested.  */
  143.  
  144. int rtl_dump = 0;
  145. int rtl_dump_and_exit = 0;
  146. int jump_opt_dump = 0;
  147. int cse_dump = 0;
  148. int loop_dump = 0;
  149. int flow_dump = 0;
  150. int combine_dump = 0;
  151. int local_reg_dump = 0;
  152. int global_reg_dump = 0;
  153. int jump2_opt_dump = 0;
  154. int dbr_sched_dump = 0;
  155.  
  156. /* 1 => write gdb debugging output (using symout.c).  -g
  157.    2 => write dbx debugging output (using dbxout.c).  -G
  158.    3 => write sdb debugging output (using sdbout.c).  -g.  */
  159.  
  160. enum debugger write_symbols = NO_DEBUG;
  161.  
  162. /* Nonzero means can use our own extensions to DBX format.
  163.    Relevant only with write_symbols == DBX_DEBUG.  */
  164.  
  165. int use_gdb_dbx_extensions;
  166.  
  167. /* Nonzero means do optimizations.  -opt.  */
  168.  
  169. int optimize = 0;
  170.  
  171. /* Nonzero means `char' should be signed.  */
  172.  
  173. int flag_signed_char;
  174.  
  175. /* Nonzero means give an enum type only as many bytes as it needs.  */
  176.  
  177. int flag_short_enums;
  178.  
  179. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  180.    be saved across function calls, if that produces overall better code.
  181.    Optional now, so people can test it.  */
  182.  
  183. #ifdef DEFAULT_CALLER_SAVES
  184. int flag_caller_saves = 1;
  185. #else
  186. int flag_caller_saves = 0;
  187. #endif
  188.  
  189. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  190.  
  191. int flag_pcc_struct_return = 0;
  192.  
  193. /* Nonzero for -fforce-mem: load memory value into a register
  194.    before arithmetic on it.  This makes better cse but slower compilation.  */
  195.  
  196. int flag_force_mem = 0;
  197.  
  198. /* Nonzero for -fforce-addr: load memory address into a register before
  199.    reference to memory.  This makes better cse but slower compilation.  */
  200.  
  201. int flag_force_addr = 0;
  202.  
  203. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  204.    instead save them up to pop many calls' args with one insns.  */
  205.  
  206. int flag_defer_pop = 1;
  207.  
  208. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  209.    in extended-precision registers.  */
  210.  
  211. int flag_float_store = 0;
  212.  
  213. /* Nonzero for -fcombine-regs:
  214.    allow instruction combiner to combine an insn
  215.    that just copies one reg to another.  */
  216.  
  217. int flag_combine_regs = 0;
  218.  
  219. /* Nonzero enables strength-reduction in loop.c.  */
  220.  
  221. int flag_strength_reduce = 0;
  222.  
  223. /* Nonzero for -fwritable-strings:
  224.    store string constants in data segment and don't uniquize them.  */
  225.  
  226. int flag_writable_strings = 0;
  227.  
  228. /* Nonzero means don't put addresses of constant functions in registers.
  229.    Used for compiling the Unix kernel, where strange substitutions are
  230.    done on the assembly output.  */
  231.  
  232. int flag_no_function_cse = 0;
  233.  
  234. /* Nonzero for -fomit-frame-pointer:
  235.    don't make a frame pointer in simple functions that don't require one.  */
  236.  
  237. int flag_omit_frame_pointer = 0;
  238.  
  239. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  240.  
  241. int flag_no_peephole = 0;
  242.  
  243. /* Nonzero means all references through pointers are volatile.  */
  244.  
  245. int flag_volatile;
  246.  
  247. /* Nonzero means just do syntax checking; don't output anything.  */
  248.  
  249. int flag_syntax_only = 0;
  250.  
  251. /* Nonzero means do stupid register allocation.  -noreg.
  252.    This and `optimize' are controlled by different switches in cc1,
  253.    but normally cc controls them both with the -O switch.  */
  254.  
  255. int obey_regdecls = 0;
  256.  
  257. /* Don't print functions as they are compiled and don't print
  258.    times taken by the various passes.  -quiet.  */
  259.  
  260. int quiet_flag = 0;
  261.  
  262. /* Don't print warning messages.  -w.  */
  263.  
  264. int inhibit_warnings = 0;
  265.  
  266. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  267.  
  268. int extra_warnings = 0;
  269.  
  270. /* Nonzero to warn about unused local variables.  */
  271.  
  272. int warn_unused;
  273.  
  274. /* Nonzero means warn about all declarations which shadow others.   */
  275.  
  276. int warn_shadow;
  277.  
  278. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  279.  
  280. int warn_switch;
  281.  
  282. /* Nonzero means warn about any identifiers that match in the first N
  283.    characters.  The value N is in `id_clash_len'.  */
  284.  
  285. int warn_id_clash;
  286. int id_clash_len;
  287.  
  288. /* Number of error messages and warning messages so far.  */
  289.  
  290. int errorcount = 0;
  291. int warningcount = 0;
  292. int sorrycount = 0;
  293.  
  294. /* Name of program invoked, sans directories.  */
  295.  
  296. char *progname;
  297.  
  298. /* Nonzero if generating code to do profiling.  */
  299.  
  300. int profile_flag = 0;
  301.  
  302. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  303.  
  304. int profile_block_flag;
  305.  
  306. /* Nonzero for -pedantic switch: warn about anything
  307.    that standard spec forbids.  */
  308.  
  309. int pedantic = 0;
  310.  
  311. /* Nonzero for -finline-functions: ok to inline functions that look like
  312.    good inline candidates.  */
  313.  
  314. int flag_inline_functions;
  315.  
  316. /* Nonzero for -fkeep-inline-functions: even if we make a function
  317.    go inline everywhere, keep its defintion around for debugging
  318.    purposes.  */
  319.  
  320. int flag_keep_inline_functions;
  321.  
  322. /* Nonzero means make the text shared if supported.  */
  323.  
  324. int flag_shared_data;
  325.  
  326. /* Nonzero means schedule into delayed branch slots if supported.  */
  327.  
  328. int flag_delayed_branch;
  329.  
  330. /* Copy of arguments to main.  */
  331. int save_argc;
  332. char **save_argv;
  333.  
  334. /* Name for output file of assembly code, specified with -o.  */
  335.  
  336. char *asm_file_name;
  337.  
  338. /* Name for output file of GDB symbol segment, specified with -symout.  */
  339.  
  340. char *sym_file_name;
  341.  
  342. /* Table of language-independent -f options.
  343.    STRING is the option name.  VARIABLE is the address of the variable.
  344.    ON_VALUE is the value to store in VARIABLE
  345.     if `-fSTRING' is seen as an option.
  346.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  347.  
  348. struct { char *string; int *variable; int on_value;} f_options[] =
  349. {
  350.   {"float-store", &flag_float_store, 1},
  351.   {"volatile", &flag_volatile, 1},
  352.   {"defer-pop", &flag_defer_pop, 1},
  353.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  354.   {"strength-reduce", &flag_strength_reduce, 1},
  355.   {"writable-strings", &flag_writable_strings, 1},
  356.   {"peephole", &flag_no_peephole, 0},
  357.   {"force-mem", &flag_force_mem, 1},
  358.   {"force-addr", &flag_force_addr, 1},
  359.   {"combine-regs", &flag_combine_regs, 1},
  360.   {"function-cse", &flag_no_function_cse, 0},
  361.   {"inline-functions", &flag_inline_functions, 1},
  362.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  363.   {"syntax-only", &flag_syntax_only, 1},
  364.   {"shared-data", &flag_shared_data, 1},
  365.   {"caller-saves", &flag_caller_saves, 1},
  366.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  367.   {"delayed-branch", &flag_delayed_branch, 1}
  368. };
  369.  
  370. /* Output files for assembler code (real compiler output)
  371.    and debugging dumps.  */
  372.  
  373. FILE *asm_out_file;
  374. FILE *rtl_dump_file;
  375. FILE *jump_opt_dump_file;
  376. FILE *cse_dump_file;
  377. FILE *loop_dump_file;
  378. FILE *flow_dump_file;
  379. FILE *combine_dump_file;
  380. FILE *local_reg_dump_file;
  381. FILE *global_reg_dump_file;
  382. FILE *jump2_opt_dump_file;
  383. FILE *dbr_sched_dump_file;
  384.  
  385. /* Time accumulators, to count the total time spent in various passes.  */
  386.  
  387. int parse_time;
  388. int varconst_time;
  389. int integration_time;
  390. int jump_time;
  391. int cse_time;
  392. int loop_time;
  393. int flow_time;
  394. int combine_time;
  395. int local_alloc_time;
  396. int global_alloc_time;
  397. int dbr_sched_time;
  398. int final_time;
  399. int symout_time;
  400. int dump_time;
  401.  
  402. /* Return time used so far, in microseconds.  */
  403.  
  404. int
  405. gettime ()
  406. {
  407. #ifdef USG
  408.   struct tms tms;
  409. #else
  410. #ifndef VMS
  411.   struct rusage rusage;
  412. #else /* VMS */
  413.   struct
  414.     {
  415.       int proc_user_time;
  416.       int proc_system_time;
  417.       int child_user_time;
  418.       int child_system_time;
  419.     } vms_times;
  420. #endif
  421. #endif
  422.  
  423.   if (quiet_flag)
  424.     return 0;
  425.  
  426. #ifdef USG
  427.   times (&tms);
  428.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  429. #else
  430. #ifndef VMS
  431.   getrusage (0, &rusage);
  432.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  433.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  434. #else /* VMS */
  435.   times (&vms_times);
  436.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  437. #endif
  438. #endif
  439. }
  440.  
  441. #define TIMEVAR(VAR, BODY)    \
  442. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  443.  
  444. void
  445. print_time (str, total)
  446.      char *str;
  447.      int total;
  448. {
  449.   fprintf (stderr,
  450.        "time in %s: %d.%06d\n",
  451.        str, total / 1000000, total % 1000000);
  452. }
  453.  
  454. /* Count an error or warning.  Return 1 if the message should be printed.  */
  455.  
  456. int
  457. count_error (warningp)
  458.      int warningp;
  459. {
  460.   if (warningp && inhibit_warnings)
  461.     return 0;
  462.  
  463.   if (warningp)
  464.     warningcount++;
  465.   else
  466.     errorcount++;
  467.  
  468.   return 1;
  469. }
  470.  
  471. /* Print a fatal error message.  NAME is the text.
  472.    Also include a system error message based on `errno'.  */
  473.  
  474. void
  475. pfatal_with_name (name)
  476.      char *name;
  477. {
  478.   fprintf (stderr, "%s: ", progname);
  479.   perror (name);
  480.   exit (35);
  481. }
  482.  
  483. void
  484. fatal_io_error (name)
  485.      char *name;
  486. {
  487.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  488.   exit (35);
  489. }
  490.  
  491. void
  492. fatal (s, v)
  493.      char *s;
  494.      int v;
  495. {
  496.   error (s, v);
  497.   exit (34);
  498. }
  499.  
  500. /* Called from insn-extract to give a better error message when we
  501.    don't have an insn to match what we are looking for, rather
  502.    than just calling abort().  */
  503.  
  504. void
  505. fatal_insn_not_found (insn)
  506.      rtx insn;
  507. {
  508.   error ("The following insn was not recognizable:", 0);
  509.   debug_rtx (insn);
  510.   abort ();
  511. }
  512.  
  513. static int need_error_newline;
  514.  
  515. /* Function of last error message;
  516.    more generally, function such that if next error message is in it
  517.    then we don't have to mention the function name.  */
  518. static tree last_error_function = NULL;
  519.  
  520. /* Used to detect when input_file_stack has changed since last described.  */
  521. static int last_error_tick;
  522.  
  523. /* Called when the start of a function definition is parsed,
  524.    this function prints on stderr the name of the function.  */
  525.  
  526. void
  527. announce_function (decl)
  528.      tree decl;
  529. {
  530.   if (! quiet_flag)
  531.     {
  532.       fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
  533.       fflush (stderr);
  534.       need_error_newline = 1;
  535.       last_error_function = current_function_decl;
  536.     }
  537. }
  538.  
  539. /* Prints out, if necessary, the name of the current function
  540.    which caused an error.  Called from all error and warning functions.  */
  541.  
  542. void
  543. report_error_function (file)
  544.      char *file;
  545. {
  546.   struct file_stack *p;
  547.  
  548.   if (need_error_newline)
  549.     {
  550.       fprintf (stderr, "\n");
  551.       need_error_newline = 0;
  552.     }
  553.  
  554.   if (last_error_function != current_function_decl)
  555.     {
  556.       if (file)
  557.     fprintf (stderr, "%s: ", file);
  558.  
  559.       if (current_function_decl == NULL)
  560.     fprintf (stderr, "At top level:\n");
  561.       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  562.     fprintf (stderr, "In method %s:\n",
  563.          DECL_PRINT_NAME (current_function_decl));
  564.       else
  565.     fprintf (stderr, "In function %s:\n",
  566.          DECL_PRINT_NAME (current_function_decl));
  567.  
  568.       last_error_function = current_function_decl;
  569.     }
  570.   if (input_file_stack && input_file_stack->next != 0
  571.       && input_file_stack_tick != last_error_tick)
  572.     {
  573.       fprintf (stderr, "In file included");
  574.       for (p = input_file_stack->next; p; p = p->next)
  575.     {
  576.       fprintf (stderr, " from %s:%d", p->name, p->line);
  577.       if (p->next)
  578.         fprintf (stderr, ",");
  579.     }
  580.       fprintf (stderr, ":\n");
  581.       last_error_tick = input_file_stack_tick;
  582.     }
  583. }
  584.  
  585. /* Report an error at the current line number.
  586.    S and V are a string and an arg for `printf'.  */
  587.  
  588. void
  589. error (s, v, v2)
  590.      char *s;
  591.      int v;            /* @@@@also used as pointer */
  592.      int v2;            /* @@@@also used as pointer */
  593. {
  594.   error_with_file_and_line (input_filename, lineno, s, v, v2);
  595. }
  596.  
  597. /* Report an error at line LINE of file FILE.
  598.    S and V are a string and an arg for `printf'.  */
  599.  
  600. void
  601. error_with_file_and_line (file, line, s, v, v2)
  602.      char *file;
  603.      int line;
  604.      char *s;
  605.      int v;
  606.      int v2;
  607. {
  608.   count_error (0);
  609.  
  610.   report_error_function (file);
  611.  
  612.   if (file)
  613.     fprintf (stderr, "%s:%d: ", file, line);
  614.   else
  615.     fprintf (stderr, "%s: ", progname);
  616.   fprintf (stderr, s, v, v2);
  617.   fprintf (stderr, "\n");
  618. }
  619.  
  620. /* Report an error at the declaration DECL.
  621.    S and V are a string and an arg which uses %s to substitute the declaration name.  */
  622.  
  623. void
  624. error_with_decl (decl, s, v)
  625.      tree decl;
  626.      char *s;
  627.      int v;
  628. {
  629.   count_error (0);
  630.  
  631.   report_error_function (DECL_SOURCE_FILE (decl));
  632.  
  633.   fprintf (stderr, "%s:%d: ",
  634.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  635.  
  636.   if (DECL_PRINT_NAME (decl))
  637.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  638.   else if (DECL_NAME (decl))
  639.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  640.   else
  641.     fprintf (stderr, s, "((anonymous))", v);
  642.   fprintf (stderr, "\n");
  643. }
  644.  
  645. /* Report an error at the line number of the insn INSN.
  646.    S and V are a string and an arg for `printf'.
  647.    This is used only when INSN is an `asm' with operands,
  648.    and each ASM_OPERANDS records its own source file and line.  */
  649.  
  650. void
  651. error_for_asm (insn, s, v, v2)
  652.      rtx insn;
  653.      char *s;
  654.      int v;            /* @@@@also used as pointer */
  655.      int v2;            /* @@@@also used as pointer */
  656. {
  657.   rtx temp;
  658.   char *filename;
  659.   int line;
  660.   rtx body = PATTERN (insn);
  661.   rtx asmop;
  662.  
  663.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  664.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  665.     asmop = SET_SRC (body);
  666.   else if (GET_CODE (body) == ASM_OPERANDS)
  667.     asmop = body;
  668.   else if (GET_CODE (body) == PARALLEL
  669.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  670.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  671.   else if (GET_CODE (body) == PARALLEL
  672.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  673.     asmop = XVECEXP (body, 0, 0);
  674.  
  675.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  676.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  677.  
  678.   error_with_file_and_line (filename, line, s, v, v2);
  679. }
  680.  
  681. /* Report a warning at line LINE.
  682.    S and V are a string and an arg for `printf'.  */
  683.  
  684. void
  685. warning_with_file_and_line (file, line, s, v, v2)
  686.      char *file;
  687.      int line;
  688.      char *s;
  689.      int v;
  690.      int v2;
  691. {
  692.   if (count_error (1) == 0)
  693.     return;
  694.  
  695.   report_error_function (file);
  696.  
  697.   if (file)
  698.     fprintf (stderr, "%s:%d: ", file, line);
  699.   else
  700.     fprintf (stderr, "%s: ", progname);
  701.  
  702.   fprintf (stderr, "warning: ");
  703.   fprintf (stderr, s, v, v2);
  704.   fprintf (stderr, "\n");
  705. }
  706.  
  707. /* Report a warning at the current line number.
  708.    S and V are a string and an arg for `printf'.  */
  709.  
  710. void
  711. warning (s, v, v2)
  712.      char *s;
  713.      int v;            /* @@@@also used as pointer */
  714.      int v2;
  715. {
  716.   warning_with_file_and_line (input_filename, lineno, s, v, v2);
  717. }
  718.  
  719. /* Report a warning at the declaration DECL.
  720.    S is string which uses %s to substitute the declaration name.
  721.    V is a second parameter that S can refer to.  */
  722.  
  723. void
  724. warning_with_decl (decl, s, v)
  725.      tree decl;
  726.      char *s;
  727.      int v;
  728. {
  729.   if (count_error (1) == 0)
  730.     return;
  731.  
  732.   report_error_function (DECL_SOURCE_FILE (decl));
  733.  
  734.   fprintf (stderr, "%s:%d: ",
  735.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  736.  
  737.   fprintf (stderr, "warning: ");
  738.   if (DECL_PRINT_NAME (decl))
  739.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  740.   else if (DECL_NAME (decl))
  741.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  742.   else
  743.     fprintf (stderr, s, "((anonymous))", v);
  744.   fprintf (stderr, "\n");
  745. }
  746.  
  747. /* Apologize for not implementing some feature.
  748.    S, V, and V2 are a string and args for `printf'.  */
  749.  
  750. void
  751. sorry (s, v, v2)
  752.      char *s;
  753.      int v, v2;
  754. {
  755.   sorrycount++;
  756.   if (input_filename)
  757.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  758.   else
  759.     fprintf (stderr, "%s: ", progname);
  760.  
  761.   fprintf (stderr, "sorry, not implemented: ");
  762.   fprintf (stderr, s, v, v2);
  763.   fprintf (stderr, "\n");
  764. }
  765.  
  766. /* Apologize for not implementing some feature, then quit.
  767.    S, V, and V2 are a string and args for `printf'.  */
  768.  
  769. void
  770. really_sorry (s, v, v2)
  771.      char *s;
  772.      int v, v2;
  773. {
  774.   if (input_filename)
  775.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  776.   else
  777.     fprintf (stderr, "c++: ");
  778.  
  779.   fprintf (stderr, "sorry, not implemented: ");
  780.   fprintf (stderr, s, v, v2);
  781.   fatal (" (fatal)\n");
  782. }
  783.  
  784. /* More 'friendly' abort that prints the line and file.
  785.    config.h can #define abort fancy_abort if you like that sort of thing.  */
  786.  
  787. void
  788. fancy_abort ()
  789. {
  790.   fatal ("Internal gcc abort.");
  791. }
  792.  
  793. /* When `malloc.c' is compiled with `rcheck' defined,
  794.    it calls this function to report clobberage.  */
  795.  
  796. void
  797. botch (s)
  798. {
  799.   abort ();
  800. }
  801.  
  802. /* Same as `malloc' but report error if no memory available.  */
  803.  
  804. int
  805. xmalloc (size)
  806.      unsigned size;
  807. {
  808.   register int value = (int) malloc (size);
  809.   if (value == 0)
  810.     fatal ("Virtual memory exhausted.");
  811.   return value;
  812. }
  813.  
  814. /* Same as `realloc' but report error if no memory available.  */
  815.  
  816. int
  817. xrealloc (ptr, size)
  818.      char *ptr;
  819.      int size;
  820. {
  821.   int result = realloc (ptr, size);
  822.   if (!result)
  823.     fatal ("Virtual memory exhausted.");
  824.   return result;
  825. }
  826.  
  827. /* Return the logarithm of X, base 2, considering X unsigned,
  828.    if X is a power of 2.  Otherwise, returns -1.  */
  829.  
  830. int
  831. exact_log2 (x)
  832.      register unsigned int x;
  833. {
  834.   register int log = 0;
  835.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  836.     if (x == (1 << log))
  837.       return log;
  838.   return -1;
  839. }
  840.  
  841. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  842.    If X is 0, return -1.  */
  843.  
  844. int
  845. floor_log2 (x)
  846.      register unsigned int x;
  847. {
  848.   register int log = 0;
  849.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  850.     if ((x & ((-1) << log)) == 0)
  851.       return log - 1;
  852.   return HOST_BITS_PER_INT - 1;
  853. }
  854.  
  855. int float_handled;
  856. jmp_buf float_handler;
  857.  
  858. /* Specify where to longjmp to when a floating arithmetic error happens.
  859.    If HANDLER is 0, it means don't handle the errors any more.  */
  860.  
  861. void
  862. set_float_handler (handler)
  863.      jmp_buf handler;
  864. {
  865.   float_handled = (handler != 0);
  866.   if (handler)
  867.     bcopy (handler, float_handler, sizeof (float_handler));
  868. }
  869.  
  870. /* Signals actually come here.  */
  871.  
  872. static void
  873. float_signal ()
  874. {
  875.   if (float_handled == 0)
  876.     abort ();
  877.   float_handled = 0;
  878.   longjmp (float_handler, 1);
  879. }
  880.  
  881. /* Handler for SIGPIPE.  */
  882.  
  883. static void
  884. pipe_closed ()
  885. {
  886.   fatal ("output pipe has been closed");
  887. }
  888.  
  889. /* Compile an entire file of output from cpp, named NAME.
  890.    Write a file of assembly output and various debugging dumps.  */
  891.  
  892. static void
  893. compile_file (name)
  894.      char *name;
  895. {
  896.   tree globals;
  897.   int start_time;
  898.   int dump_base_name_length;
  899.  
  900.   int name_specified = name != 0;
  901.  
  902.   if (dump_base_name == 0)
  903.     dump_base_name = name ? name : "gccdump";
  904.   dump_base_name_length = strlen (dump_base_name);
  905.  
  906.   parse_time = 0;
  907.   varconst_time = 0;
  908.   integration_time = 0;
  909.   jump_time = 0;
  910.   cse_time = 0;
  911.   loop_time = 0;
  912.   flow_time = 0;
  913.   combine_time = 0;
  914.   local_alloc_time = 0;
  915.   global_alloc_time = 0;
  916.   dbr_sched_time = 0;
  917.   final_time = 0;
  918.   symout_time = 0;
  919.   dump_time = 0;
  920.  
  921.   /* Open input file.  */
  922.  
  923.   if (name == 0 || !strcmp (name, "-"))
  924.     {
  925.       finput = stdin;
  926.       name = "stdin";
  927.     }
  928.   else
  929.     finput = fopen (name, "r");
  930.   if (finput == 0)
  931.     pfatal_with_name (name);
  932.  
  933.   /* Initialize data in various passes.  */
  934.  
  935.   init_tree ();
  936.   init_lex ();
  937.   init_rtl ();
  938.   init_emit_once ();
  939.   init_decl_processing ();
  940.   init_optabs ();
  941.  
  942.   /* If rtl dump desired, open the output file.  */
  943.   if (rtl_dump)
  944.     {
  945.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  946.       strcpy (dumpname, dump_base_name);
  947.       strcat (dumpname, ".rtl");
  948.       rtl_dump_file = fopen (dumpname, "w");
  949.       if (rtl_dump_file == 0)
  950.     pfatal_with_name (dumpname);
  951.     }
  952.  
  953.   /* If jump_opt dump desired, open the output file.  */
  954.   if (jump_opt_dump)
  955.     {
  956.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  957.       strcpy (dumpname, dump_base_name);
  958.       strcat (dumpname, ".jump");
  959.       jump_opt_dump_file = fopen (dumpname, "w");
  960.       if (jump_opt_dump_file == 0)
  961.     pfatal_with_name (dumpname);
  962.     }
  963.  
  964.   /* If cse dump desired, open the output file.  */
  965.   if (cse_dump)
  966.     {
  967.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  968.       strcpy (dumpname, dump_base_name);
  969.       strcat (dumpname, ".cse");
  970.       cse_dump_file = fopen (dumpname, "w");
  971.       if (cse_dump_file == 0)
  972.     pfatal_with_name (dumpname);
  973.     }
  974.  
  975.   /* If loop dump desired, open the output file.  */
  976.   if (loop_dump)
  977.     {
  978.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  979.       strcpy (dumpname, dump_base_name);
  980.       strcat (dumpname, ".loop");
  981.       loop_dump_file = fopen (dumpname, "w");
  982.       if (loop_dump_file == 0)
  983.     pfatal_with_name (dumpname);
  984.     }
  985.  
  986.   /* If flow dump desired, open the output file.  */
  987.   if (flow_dump)
  988.     {
  989.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  990.       strcpy (dumpname, dump_base_name);
  991.       strcat (dumpname, ".flow");
  992.       flow_dump_file = fopen (dumpname, "w");
  993.       if (flow_dump_file == 0)
  994.     pfatal_with_name (dumpname);
  995.     }
  996.  
  997.   /* If combine dump desired, open the output file.  */
  998.   if (combine_dump)
  999.     {
  1000.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  1001.       strcpy (dumpname, dump_base_name);
  1002.       strcat (dumpname, ".combine");
  1003.       combine_dump_file = fopen (dumpname, "w");
  1004.       if (combine_dump_file == 0)
  1005.     pfatal_with_name (dumpname);
  1006.     }
  1007.  
  1008.   /* If local_reg dump desired, open the output file.  */
  1009.   if (local_reg_dump)
  1010.     {
  1011.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1012.       strcpy (dumpname, dump_base_name);
  1013.       strcat (dumpname, ".lreg");
  1014.       local_reg_dump_file = fopen (dumpname, "w");
  1015.       if (local_reg_dump_file == 0)
  1016.     pfatal_with_name (dumpname);
  1017.     }
  1018.  
  1019.   /* If global_reg dump desired, open the output file.  */
  1020.   if (global_reg_dump)
  1021.     {
  1022.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1023.       strcpy (dumpname, dump_base_name);
  1024.       strcat (dumpname, ".greg");
  1025.       global_reg_dump_file = fopen (dumpname, "w");
  1026.       if (global_reg_dump_file == 0)
  1027.     pfatal_with_name (dumpname);
  1028.     }
  1029.  
  1030.   /* If jump2_opt dump desired, open the output file.  */
  1031.   if (jump2_opt_dump)
  1032.     {
  1033.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1034.       strcpy (dumpname, dump_base_name);
  1035.       strcat (dumpname, ".jump2");
  1036.       jump2_opt_dump_file = fopen (dumpname, "w");
  1037.       if (jump2_opt_dump_file == 0)
  1038.     pfatal_with_name (dumpname);
  1039.     }
  1040.  
  1041.   /* If dbr_sched dump desired, open the output file.  */
  1042.   if (dbr_sched_dump)
  1043.     {
  1044.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1045.       strcpy (dumpname, dump_base_name);
  1046.       strcat (dumpname, ".dbr");
  1047.       dbr_sched_dump_file = fopen (dumpname, "w");
  1048.       if (dbr_sched_dump_file == 0)
  1049.     pfatal_with_name (dumpname);
  1050.     }
  1051.  
  1052.   /* Open assembler code output file.  */
  1053.  
  1054.   if (! name_specified && asm_file_name == 0)
  1055.     asm_out_file = stdout;
  1056.   else
  1057.     {
  1058.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1059.       int len = strlen (dump_base_name);
  1060.       strcpy (dumpname, dump_base_name);
  1061.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1062.     dumpname[len - 2] = 0;
  1063.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1064.     dumpname[len - 2] = 0;
  1065.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1066.     dumpname[len - 3] = 0;
  1067.       strcat (dumpname, ".s");
  1068.       if (asm_file_name == 0)
  1069.     {
  1070.       asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  1071.       strcpy (asm_file_name, dumpname);
  1072.     }
  1073.       if (!strcmp (asm_file_name, "-"))
  1074.     asm_out_file = stdout;
  1075.       else
  1076.     asm_out_file = fopen (asm_file_name, "w");
  1077.       if (asm_out_file == 0)
  1078.     pfatal_with_name (asm_file_name);
  1079.     }
  1080.  
  1081.   input_filename = name;
  1082.  
  1083.   /* the beginning of the file is a new line; check for # */
  1084.   /* With luck, we discover the real source file's name from that
  1085.      and put it in input_filename.  */
  1086.   ungetc (check_newline (), finput);
  1087.  
  1088.   /* If the input doesn't start with a #line, use the input name
  1089.      as the official input file name.  */
  1090.   if (main_input_filename == 0)
  1091.     main_input_filename = name;
  1092.  
  1093.   /* Put an entry on the input file stack for the main input file.  */
  1094.   input_file_stack
  1095.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  1096.   input_file_stack->next = 0;
  1097.   input_file_stack->name = input_filename;
  1098.  
  1099.   ASM_FILE_START (asm_out_file);
  1100.  
  1101.   /* Output something to inform GDB that this compilation was by GCC.  */
  1102. #ifndef ASM_IDENTIFY_GCC
  1103.   fprintf (asm_out_file, "gcc_compiled.:\n");
  1104. #else
  1105.   ASM_IDENTIFY_GCC (asm_out_file);
  1106. #endif
  1107.  
  1108.   /* If GDB symbol table desired, open the GDB symbol output file.  */
  1109.   if (write_symbols == GDB_DEBUG)
  1110.     {
  1111.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1112.       int len = strlen (dump_base_name);
  1113.       strcpy (dumpname, dump_base_name);
  1114.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1115.     dumpname[len - 2] = 0;
  1116.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1117.     dumpname[len - 2] = 0;
  1118.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1119.     dumpname[len - 3] = 0;
  1120.       strcat (dumpname, ".sym");
  1121.       if (sym_file_name == 0)
  1122.     sym_file_name = dumpname;
  1123.       symout_init (sym_file_name, asm_out_file, main_input_filename);
  1124.     }
  1125.  
  1126.   /* If dbx symbol table desired, initialize writing it
  1127.      and output the predefined types.  */
  1128. #ifdef DBX_DEBUGGING_INFO
  1129.   if (write_symbols == DBX_DEBUG)
  1130.     dbxout_init (asm_out_file, main_input_filename);
  1131. #endif
  1132. #ifdef SDB_DEBUGGING_INFO
  1133.   if (write_symbols == SDB_DEBUG)
  1134.     sdbout_init (asm_out_file, main_input_filename);
  1135. #endif
  1136.  
  1137.   /* Initialize yet another pass.  */
  1138.  
  1139.   init_final (main_input_filename);
  1140.  
  1141.   start_time = gettime ();
  1142.  
  1143.   /* Call the parser, which parses the entire file
  1144.      (calling rest_of_compilation for each function).  */
  1145.  
  1146.   yyparse ();
  1147.  
  1148.   /* Compilation is now finished except for writing
  1149.      what's left of the symbol table output.  */
  1150.  
  1151.   parse_time += gettime () - start_time;
  1152.  
  1153.   parse_time -= integration_time;
  1154.   parse_time -= varconst_time;
  1155.  
  1156.   globals = getdecls ();
  1157.  
  1158.   /* Really define vars that have had only a tentative definition.
  1159.      Really output inline functions that must actually be callable
  1160.      and have not been output so far.  */
  1161.  
  1162.   {
  1163.     tree decl;
  1164.     for (decl = globals; decl; decl = TREE_CHAIN (decl))
  1165.       {
  1166.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  1167.         && ! TREE_ASM_WRITTEN (decl))
  1168.       {
  1169.         /* Don't write out static consts, unless we needed
  1170.            to take their address for some reason.  */
  1171.         if (! TREE_READONLY (decl)
  1172.         || TREE_PUBLIC (decl)
  1173.         || TREE_ADDRESSABLE (decl))
  1174.           rest_of_decl_compilation (decl, 0, 1, 1);
  1175.         /* Otherwise maybe mention them just for the debugger.  */
  1176. #ifdef DBX_DEBUGGING_INFO
  1177.         else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
  1178.           TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1179. #endif
  1180. #ifdef SDB_DEBUGGING_INFO
  1181.         else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
  1182.           TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1183. #endif
  1184.       }
  1185.     if (TREE_CODE (decl) == FUNCTION_DECL
  1186.         && ! TREE_ASM_WRITTEN (decl)
  1187.         && DECL_INITIAL (decl) != 0
  1188.         && TREE_ADDRESSABLE (decl)
  1189.         && ! TREE_EXTERNAL (decl))
  1190.       output_inline_function (decl);
  1191.  
  1192.     /* Warn about any function declared static but not defined.  */
  1193.     if (warn_unused
  1194.         && TREE_CODE (decl) == FUNCTION_DECL
  1195.         && DECL_INITIAL (decl) == 0
  1196.         && TREE_EXTERNAL (decl)
  1197.         && ! TREE_PUBLIC (decl))
  1198.       warning_with_decl (decl, "`%s' declared but never defined");
  1199.     /* Warn about statics fns or vars defined but not used,
  1200.        but not about inline functions
  1201.        since unused inline statics is normal practice.  */
  1202.     if (warn_unused
  1203.         && (TREE_CODE (decl) == FUNCTION_DECL
  1204.         || TREE_CODE (decl) == VAR_DECL)
  1205.         && ! TREE_EXTERNAL (decl)
  1206.         && ! TREE_PUBLIC (decl)
  1207.         && ! TREE_USED (decl)
  1208.         && ! TREE_INLINE (decl)
  1209.         /* The TREE_USED bit for file-scope decls
  1210.            is kept in the identifier, to handle multiple
  1211.            external decls in different scopes.  */
  1212.         && ! TREE_USED (DECL_NAME (decl)))
  1213.         /* Ignore any unused static variable named `rcsid' so we
  1214.            don't get zillions of complaints. */
  1215.         if (! DECL_PRINT_NAME (decl)
  1216.         || strcmp(DECL_PRINT_NAME(decl), "rcsid")) {
  1217.             warning_with_decl (decl, "`%s' defined but not used");
  1218.         }
  1219.       }
  1220.   }
  1221.  
  1222.   /* Do dbx symbols */
  1223. #ifdef DBX_DEBUGGING_INFO
  1224.   if (write_symbols == DBX_DEBUG)
  1225.     TIMEVAR (symout_time,
  1226.          {
  1227.            dbxout_tags (gettags ());
  1228.            dbxout_types (get_permanent_types ());
  1229.          });
  1230. #endif
  1231.  
  1232. #ifdef SDB_DEBUGGING_INFO
  1233.   if (write_symbols == SDB_DEBUG)
  1234.     TIMEVAR (symout_time,
  1235.          {
  1236.            sdbout_tags (gettags ());
  1237.            sdbout_types (get_permanent_types ());
  1238.          });
  1239. #endif
  1240.  
  1241.   /* Do gdb symbols */
  1242.   if (write_symbols == GDB_DEBUG)
  1243.     TIMEVAR (symout_time,
  1244.          {
  1245.            struct stat statbuf;
  1246.            fstat (fileno (finput), &statbuf);
  1247.            symout_types (get_permanent_types ());
  1248.            symout_top_blocks (globals, gettags ());
  1249.            symout_finish (name, statbuf.st_ctime);
  1250.          });
  1251.  
  1252.   /* Output some stuff at end of file if nec.  */
  1253.  
  1254.   end_final (main_input_filename);
  1255.  
  1256. #ifdef ASM_FILE_END
  1257.   ASM_FILE_END (asm_out_file);
  1258. #endif
  1259.  
  1260.   /* Close the dump files.  */
  1261.  
  1262.   if (rtl_dump)
  1263.     fclose (rtl_dump_file);
  1264.  
  1265.   if (jump_opt_dump)
  1266.     fclose (jump_opt_dump_file);
  1267.  
  1268.   if (cse_dump)
  1269.     fclose (cse_dump_file);
  1270.  
  1271.   if (loop_dump)
  1272.     fclose (loop_dump_file);
  1273.  
  1274.   if (flow_dump)
  1275.     fclose (flow_dump_file);
  1276.  
  1277.   if (combine_dump)
  1278.     {
  1279.       dump_combine_total_stats (combine_dump_file);
  1280.       fclose (combine_dump_file);
  1281.     }
  1282.  
  1283.   if (local_reg_dump)
  1284.     fclose (local_reg_dump_file);
  1285.  
  1286.   if (global_reg_dump)
  1287.     fclose (global_reg_dump_file);
  1288.  
  1289.   if (jump2_opt_dump)
  1290.     fclose (jump2_opt_dump_file);
  1291.  
  1292.   if (dbr_sched_dump)
  1293.     fclose (dbr_sched_dump_file);
  1294.  
  1295.   /* Close non-debugging input and output files.  Take special care to note
  1296.      whether fclose returns an error, since the pages might still be on the
  1297.      buffer chain while the file is open.  */
  1298.  
  1299.   fclose (finput);
  1300.   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
  1301.     fatal_io_error (asm_file_name);
  1302.  
  1303.   /* Print the times.  */
  1304.  
  1305.   if (! quiet_flag)
  1306.     {
  1307.       fprintf (stderr,"\n");
  1308.       print_time ("parse", parse_time);
  1309.       print_time ("integration", integration_time);
  1310.       print_time ("jump", jump_time);
  1311.       print_time ("cse", cse_time);
  1312.       print_time ("loop", loop_time);
  1313.       print_time ("flow", flow_time);
  1314.       print_time ("combine", combine_time);
  1315.       print_time ("local-alloc", local_alloc_time);
  1316.       print_time ("global-alloc", global_alloc_time);
  1317.       print_time ("dbranch", dbr_sched_time);
  1318.       print_time ("final", final_time);
  1319.       print_time ("varconst", varconst_time);
  1320.       print_time ("symout", symout_time);
  1321.       print_time ("dump", dump_time);
  1322.     }
  1323. }
  1324.  
  1325. /* This is called from finish_decl (within yyparse)
  1326.    for each declaration of a function or variable.
  1327.    This does nothing for automatic variables.
  1328.    Otherwise, it sets up the RTL and outputs any assembler code
  1329.    (label definition, storage allocation and initialization).
  1330.  
  1331.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  1332.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  1333.    if this declaration is not within a function.  */
  1334.  
  1335. void
  1336. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  1337.      tree decl;
  1338.      char *asmspec;
  1339.      int top_level;
  1340.      int at_end;
  1341. {
  1342.   /* Declarations of variables, and of functions defined elsewhere.  */
  1343.  
  1344.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  1345.     TIMEVAR (varconst_time,
  1346.          {
  1347.            make_decl_rtl (decl, asmspec, top_level);
  1348.            /* Don't output anything
  1349.           when a tentative file-scope definition is seen.
  1350.           But at end of compilation, do output code for them.  */
  1351.            if (! (! at_end && top_level
  1352.               && (DECL_INITIAL (decl) == 0
  1353.               || DECL_INITIAL (decl) == error_mark_node)))
  1354.          assemble_variable (decl, top_level, write_symbols, at_end);
  1355.          });
  1356.   else if (TREE_REGDECL (decl) && asmspec != 0)
  1357.     {
  1358.       if (decode_reg_name (asmspec) >= 0)
  1359.     {
  1360.       DECL_RTL (decl) = 0;
  1361.       make_decl_rtl (decl, asmspec, top_level);
  1362.     }
  1363.       else
  1364.     error ("invalid register name `%s' for register variable", asmspec);
  1365.     }
  1366. #ifdef DBX_DEBUGGING_INFO
  1367.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1368.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1369. #endif
  1370. #ifdef SDB_DEBUGGING_INFO
  1371.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1372.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1373. #endif
  1374.  
  1375.   if (top_level)
  1376.     {
  1377.       if (write_symbols == GDB_DEBUG)
  1378.     {
  1379.       TIMEVAR (symout_time,
  1380.            {
  1381.              /* The initizations make types when they contain
  1382.             string constants.  The types are on the temporary
  1383.             obstack, so output them now before they go away.  */
  1384.              symout_types (get_temporary_types ());
  1385.            });
  1386.     }
  1387.       else
  1388.     /* Clean out the temporary type list, since the types will go away.  */
  1389.     get_temporary_types ();
  1390.     }
  1391. }
  1392.  
  1393. /* This is called from finish_function (within yyparse)
  1394.    after each top-level definition is parsed.
  1395.    It is supposed to compile that function or variable
  1396.    and output the assembler code for it.
  1397.    After we return, the tree storage is freed.  */
  1398.  
  1399. void
  1400. rest_of_compilation (decl)
  1401.      tree decl;
  1402. {
  1403.   register rtx insns;
  1404.   int start_time = gettime ();
  1405.   int tem;
  1406.  
  1407.   /* If we are reconsidering an inline function
  1408.      at the end of compilation, skip the stuff for making it inline.  */
  1409.  
  1410.   if (DECL_SAVED_INSNS (decl) == 0)
  1411.     {
  1412.  
  1413.       /* If requested, consider whether to make this function inline.  */
  1414.       if (flag_inline_functions || TREE_INLINE (decl))
  1415.     {
  1416.       TIMEVAR (integration_time,
  1417.            {
  1418.              int specd = TREE_INLINE (decl);
  1419.              char *lose = function_cannot_inline_p (decl);
  1420.              if (lose != 0 && specd)
  1421.                warning_with_decl (decl, lose);
  1422.              if (lose == 0)
  1423.                save_for_inline (decl);
  1424.              else
  1425.                TREE_INLINE (decl) = 0;
  1426.            });
  1427.     }
  1428.  
  1429.       insns = get_insns ();
  1430.  
  1431.       /* Dump the rtl code if we are dumping rtl.  */
  1432.  
  1433.       if (rtl_dump)
  1434.     TIMEVAR (dump_time,
  1435.          {
  1436.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1437.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1438.            if (DECL_SAVED_INSNS (decl))
  1439.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1440.            print_rtl (rtl_dump_file, insns);
  1441.            fflush (rtl_dump_file);
  1442.          });
  1443.  
  1444.       /* If function is inline, and we don't yet know whether to
  1445.      compile it by itself, defer decision till end of compilation.
  1446.      finish_compilation will call rest_of_compilation again
  1447.      for those functions that need to be output.  */
  1448.  
  1449.       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  1450.         && ! flag_keep_inline_functions)
  1451.        || TREE_EXTERNAL (decl))
  1452.       && TREE_INLINE (decl))
  1453.     goto exit_rest_of_compilation;
  1454.     }
  1455.  
  1456.   if (rtl_dump_and_exit || flag_syntax_only)
  1457.     {
  1458.       get_temporary_types ();
  1459.       goto exit_rest_of_compilation;
  1460.     }
  1461.  
  1462.   TREE_ASM_WRITTEN (decl) = 1;
  1463.  
  1464.   insns = get_insns ();
  1465.  
  1466.   /* Copy any shared structure that should not be shared.  */
  1467.  
  1468.   unshare_all_rtl (insns);
  1469.  
  1470.   /* See if we have allocated stack slots that are not directly addressable.
  1471.      If so, scan all the insns and create explicit address computation
  1472.      for all references to such slots.  */
  1473. /*   fixup_stack_slots (); */
  1474.  
  1475.   /* Do jump optimization the first time, if -opt.
  1476.      Also do it if -W, but in that case it doesn't change the rtl code,
  1477.      it only computes whether control can drop off the end of the function.  */
  1478.  
  1479.   if (optimize || extra_warnings || warn_return_type
  1480.       /* If function is `volatile', we should warn if it tries to return.  */
  1481.       || TREE_THIS_VOLATILE (decl))
  1482.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1483.  
  1484.   /* Dump rtl code after jump, if we are doing that.  */
  1485.  
  1486.   if (jump_opt_dump)
  1487.     TIMEVAR (dump_time,
  1488.          {
  1489.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1490.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1491.            print_rtl (jump_opt_dump_file, insns);
  1492.            fflush (jump_opt_dump_file);
  1493.          });
  1494.  
  1495.   /* Perform common subexpression elimination.
  1496.      Nonzero value from `cse_main' means that jumps were simplified
  1497.      and some code may now be unreachable, so do
  1498.      jump optimization again.  */
  1499.  
  1500.   if (optimize)
  1501.     {
  1502.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1503.  
  1504.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  1505.  
  1506.       if (tem)
  1507.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1508.     }
  1509.  
  1510.   /* Dump rtl code after cse, if we are doing that.  */
  1511.  
  1512.   if (cse_dump)
  1513.     TIMEVAR (dump_time,
  1514.          {
  1515.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1516.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1517.            print_rtl (cse_dump_file, insns);
  1518.            fflush (cse_dump_file);
  1519.          });
  1520.  
  1521.   if (loop_dump)
  1522.     TIMEVAR (dump_time,
  1523.          {
  1524.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1525.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1526.          });
  1527.  
  1528.   /* Move constant computations out of loops.  */
  1529.  
  1530.   if (optimize)
  1531.     {
  1532.       TIMEVAR (loop_time,
  1533.            {
  1534.          reg_scan (insns, max_reg_num (), 1);
  1535.          loop_optimize (insns, loop_dump ? loop_dump_file : 0);
  1536.            });
  1537.     }
  1538.  
  1539.   /* Dump rtl code after loop opt, if we are doing that.  */
  1540.  
  1541.   if (loop_dump)
  1542.     TIMEVAR (dump_time,
  1543.          {
  1544.            print_rtl (loop_dump_file, insns);
  1545.            fflush (loop_dump_file);
  1546.          });
  1547.  
  1548.   /* Now we choose between stupid (pcc-like) register allocation
  1549.      (if we got the -noreg switch and not -opt)
  1550.      and smart register allocation.  */
  1551.  
  1552.   if (optimize)        /* Stupid allocation probably won't work */
  1553.     obey_regdecls = 0;    /* if optimizations being done.  */
  1554.  
  1555.   regclass_init ();
  1556.  
  1557.   /* Print function header into flow dump now
  1558.      because doing the flow analysis makes some of the dump.  */
  1559.  
  1560.   if (flow_dump)
  1561.     TIMEVAR (dump_time,
  1562.          {
  1563.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1564.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1565.          });
  1566.  
  1567.   if (obey_regdecls)
  1568.     {
  1569.       TIMEVAR (flow_time,
  1570.            {
  1571.          regclass (insns, max_reg_num ());
  1572.          stupid_life_analysis (insns, max_reg_num (),
  1573.                        flow_dump_file);
  1574.            });
  1575.     }
  1576.   else
  1577.     {
  1578.       /* Do control and data flow analysis,
  1579.      and write some of the results to dump file.  */
  1580.  
  1581.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1582.                      flow_dump_file));
  1583.       if (extra_warnings)
  1584.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1585.     }
  1586.  
  1587.   /* Dump rtl after flow analysis.  */
  1588.  
  1589.   if (flow_dump)
  1590.     TIMEVAR (dump_time,
  1591.          {
  1592.            print_rtl (flow_dump_file, insns);
  1593.            fflush (flow_dump_file);
  1594.          });
  1595.  
  1596.   /* If -opt, try combining insns through substitution.  */
  1597.  
  1598.   if (optimize)
  1599.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1600.  
  1601.   /* Dump rtl code after insn combination.  */
  1602.  
  1603.   if (combine_dump)
  1604.     TIMEVAR (dump_time,
  1605.          {
  1606.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1607.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1608.            dump_combine_stats (combine_dump_file);
  1609.            print_rtl (combine_dump_file, insns);
  1610.            fflush (combine_dump_file);
  1611.          });
  1612.  
  1613.   /* Unless we did stupid register allocation,
  1614.      allocate pseudo-regs that are used only within 1 basic block.  */
  1615.  
  1616.   if (!obey_regdecls)
  1617.     TIMEVAR (local_alloc_time,
  1618.          {
  1619.            regclass (insns, max_reg_num ());
  1620.            local_alloc ();
  1621.          });
  1622.  
  1623.   /* Dump rtl code after allocating regs within basic blocks.  */
  1624.  
  1625.   if (local_reg_dump)
  1626.     TIMEVAR (dump_time,
  1627.          {
  1628.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1629.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1630.            dump_flow_info (local_reg_dump_file);
  1631.            dump_local_alloc (local_reg_dump_file);
  1632.            print_rtl (local_reg_dump_file, insns);
  1633.            fflush (local_reg_dump_file);
  1634.          });
  1635.  
  1636.   if (global_reg_dump)
  1637.     TIMEVAR (dump_time,
  1638.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1639.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1640.  
  1641.   /* Unless we did stupid register allocation,
  1642.      allocate remaining pseudo-regs, then do the reload pass
  1643.      fixing up any insns that are invalid.  */
  1644.  
  1645.   TIMEVAR (global_alloc_time,
  1646.        {
  1647.          if (!obey_regdecls)
  1648.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  1649.          else
  1650.            reload (insns, 0,
  1651.                global_reg_dump ? global_reg_dump_file : 0);
  1652.        });
  1653.  
  1654.   if (global_reg_dump)
  1655.     TIMEVAR (dump_time,
  1656.          {
  1657.            dump_global_regs (global_reg_dump_file);
  1658.            print_rtl (global_reg_dump_file, insns);
  1659.            fflush (global_reg_dump_file);
  1660.          });
  1661.  
  1662.   rtx_equal_function_value_matters = 1;
  1663.   reload_completed = 1;
  1664.  
  1665.   /* One more attempt to remove jumps to .+1
  1666.      left by dead-store-elimination.
  1667.      Also do cross-jumping this time
  1668.      and delete no-op move insns.  */
  1669.  
  1670.   if (optimize)
  1671.     {
  1672.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  1673.     }
  1674.  
  1675.   /* Dump rtl code after jump, if we are doing that.  */
  1676.  
  1677.   if (jump2_opt_dump)
  1678.     TIMEVAR (dump_time,
  1679.          {
  1680.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  1681.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1682.            print_rtl (jump2_opt_dump_file, insns);
  1683.            fflush (jump2_opt_dump_file);
  1684.          });
  1685.  
  1686.   /* If a scheduling pass for delayed branches is to be done,
  1687.      call the scheduling code. */
  1688.  
  1689. #ifdef HAVE_DELAYED_BRANCH
  1690.   if (optimize && flag_delayed_branch)
  1691.     {
  1692.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  1693.       if (dbr_sched_dump)
  1694.     {
  1695.       TIMEVAR (dump_time,
  1696.          {
  1697.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  1698.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1699.            print_rtl (dbr_sched_dump_file, insns);
  1700.            fflush (dbr_sched_dump_file);
  1701.          });
  1702.     }
  1703.     }
  1704. #endif
  1705.  
  1706.   /* Now turn the rtl into assembler code.  */
  1707.  
  1708.   TIMEVAR (final_time,
  1709.        {
  1710.          assemble_function (decl);
  1711.          final_start_function (insns, asm_out_file,
  1712.                    write_symbols, optimize);
  1713.          final (insns, asm_out_file,
  1714.             write_symbols, optimize, 0);
  1715.          final_end_function (insns, asm_out_file,
  1716.                  write_symbols, optimize);
  1717.          fflush (asm_out_file);
  1718.        });
  1719.  
  1720.   /* Write GDB symbols if requested */
  1721.  
  1722.   if (write_symbols == GDB_DEBUG)
  1723.     {
  1724.       TIMEVAR (symout_time,
  1725.            {
  1726.          symout_types (get_permanent_types ());
  1727.          symout_types (get_temporary_types ());
  1728.  
  1729.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  1730.            = symout_function (DECL_INITIAL (decl),
  1731.                       DECL_ARGUMENTS (decl), 0);
  1732.          symout_function_end ();
  1733.            });
  1734.     }
  1735.   else
  1736.     get_temporary_types ();
  1737.  
  1738.   /* Write DBX symbols if requested */
  1739.  
  1740. #ifdef DBX_DEBUGGING_INFO
  1741.   if (write_symbols == DBX_DEBUG)
  1742.     TIMEVAR (symout_time, dbxout_function (decl));
  1743. #endif
  1744.  
  1745.  exit_rest_of_compilation:
  1746.  
  1747.   rtx_equal_function_value_matters = 0;
  1748.   reload_completed = 0;
  1749.  
  1750.   /* Clear out the real_constant_chain before some of the rtx's
  1751.      it runs through become garbage.  */
  1752.  
  1753.   clear_const_double_mem ();
  1754.  
  1755.   /* The parsing time is all the time spent in yyparse
  1756.      *except* what is spent in this function.  */
  1757.  
  1758.   parse_time -= gettime () - start_time;
  1759. }
  1760.  
  1761. /* Entry point of cc1.  Decode command args, then call compile_file.
  1762.    Exit code is 35 if can't open files, 34 if fatal error,
  1763.    33 if had nonfatal errors, else success.  */
  1764.  
  1765. int
  1766. main (argc, argv, envp)
  1767.      int argc;
  1768.      char **argv;
  1769.      char **envp;
  1770. {
  1771.   register int i;
  1772.   char *filename = 0;
  1773.   int print_mem_flag = 0;
  1774.   char *p;
  1775.  
  1776.   /* save in case md file wants to emit args as a comment.  */
  1777.   save_argc = argc;
  1778.   save_argv = argv;
  1779.  
  1780.   p = argv[0] + strlen (argv[0]);
  1781.   while (p != argv[0] && p[-1] != '/') --p;
  1782.   progname = p;
  1783.  
  1784. #ifdef RLIMIT_STACK
  1785.   /* Get rid of any avoidable limit on stack size.  */
  1786.   {
  1787.     struct rlimit rlim;
  1788.  
  1789.     /* Set the stack limit huge so that alloca does not fail. */
  1790.     getrlimit (RLIMIT_STACK, &rlim);
  1791.     rlim.rlim_cur = rlim.rlim_max;
  1792.     setrlimit (RLIMIT_STACK, &rlim);
  1793.   }
  1794. #endif /* RLIMIT_STACK */
  1795.  
  1796.   signal (SIGFPE, float_signal);
  1797.  
  1798.   signal (SIGPIPE, pipe_closed);
  1799.  
  1800.   /* Initialize whether `char' is signed.  */
  1801.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  1802. #ifdef DEFAULT_SHORT_ENUMS
  1803.   /* Initialize how much space enums occupy, by default.  */
  1804.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  1805. #endif
  1806.  
  1807.   /* This is zeroed by -O.  */
  1808.   obey_regdecls = 1;
  1809.  
  1810.   /* Initialize register usage now so switches may override.  */
  1811.   init_reg_sets ();
  1812.  
  1813.   target_flags = 0;
  1814.   set_target_switch ("");
  1815.  
  1816.   for (i = 1; i < argc; i++)
  1817.     if (argv[i][0] == '-' && argv[i][1] != 0)
  1818.       {
  1819.     register char *str = argv[i] + 1;
  1820.     if (str[0] == 'Y')
  1821.       str++;
  1822.  
  1823.     if (str[0] == 'm')
  1824.       set_target_switch (&str[1]);
  1825.     else if (!strcmp (str, "dumpbase"))
  1826.       {
  1827.         dump_base_name = argv[++i];
  1828.       }
  1829.     else if (str[0] == 'd')
  1830.       {
  1831.         register char *p = &str[1];
  1832.         while (*p)
  1833.           switch (*p++)
  1834.         {
  1835.         case 'c':
  1836.           combine_dump = 1;
  1837.           break;
  1838.         case 'd':
  1839.           dbr_sched_dump = 1;
  1840.           break;
  1841.         case 'f':
  1842.           flow_dump = 1;
  1843.           break;
  1844.         case 'g':
  1845.           global_reg_dump = 1;
  1846.           break;
  1847.         case 'j':
  1848.           jump_opt_dump = 1;
  1849.           break;
  1850.         case 'J':
  1851.           jump2_opt_dump = 1;
  1852.           break;
  1853.         case 'l':
  1854.           local_reg_dump = 1;
  1855.           break;
  1856.         case 'L':
  1857.           loop_dump = 1;
  1858.           break;
  1859.         case 'm':
  1860.           print_mem_flag = 1;
  1861.           break;
  1862.         case 'r':
  1863.           rtl_dump = 1;
  1864.           break;
  1865.         case 's':
  1866.           cse_dump = 1;
  1867.           break;
  1868.         case 'y':
  1869.           yydebug = 1;
  1870.           break;
  1871.         }
  1872.       }
  1873.     else if (str[0] == 'f')
  1874.       {
  1875.         int j;
  1876.         register char *p = &str[1];
  1877.         int found = 0;
  1878.  
  1879.         /* Some kind of -f option.
  1880.            P's value is the option sans `-f'.
  1881.            Search for it in the table of options.  */
  1882.  
  1883.         for (j = 0;
  1884.          !found && j < sizeof (f_options) / sizeof (f_options[0]);
  1885.          j++)
  1886.           {
  1887.         if (!strcmp (p, f_options[j].string))
  1888.           {
  1889.             *f_options[j].variable = f_options[j].on_value;
  1890.             /* A goto here would be cleaner,
  1891.                but breaks the vax pcc.  */
  1892.             found = 1;
  1893.           }
  1894.         if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  1895.             && ! strcmp (p+3, f_options[j].string))
  1896.           {
  1897.             *f_options[j].variable = ! f_options[j].on_value;
  1898.             found = 1;
  1899.           }
  1900.           }
  1901.  
  1902.         if (found)
  1903.           ;
  1904.         else if (!strncmp (p, "fixed-", 6))
  1905.           fix_register (&p[6], 1, 1);
  1906.         else if (!strncmp (p, "call-used-", 10))
  1907.           fix_register (&p[10], 0, 1);
  1908.         else if (!strncmp (p, "call-saved-", 11))
  1909.           fix_register (&p[11], 0, 0);
  1910.         else if (! lang_decode_option (argv[i]))
  1911.           error ("Invalid option `%s'", argv[i]);
  1912.       }
  1913.     else if (!strcmp (str, "noreg"))
  1914.       ;
  1915.     else if (!strcmp (str, "opt"))
  1916.       optimize = 1, obey_regdecls = 0;
  1917.     else if (!strcmp (str, "O"))
  1918.       optimize = 1, obey_regdecls = 0;
  1919.     else if (!strcmp (str, "pedantic"))
  1920.       pedantic = 1;
  1921.     else if (lang_decode_option (argv[i]))
  1922.       ;
  1923.     else if (!strcmp (str, "quiet"))
  1924.       quiet_flag = 1;
  1925.     else if (!strcmp (str, "version"))
  1926.       {
  1927.         extern char *version_string, *language_string;
  1928.         fprintf (stderr, "%s version %s", language_string, version_string);
  1929. #ifdef TARGET_VERSION
  1930.         TARGET_VERSION;
  1931. #endif
  1932. #ifdef __GNUC__
  1933. #ifndef __VERSION__
  1934. #define __VERSION__ "[unknown]"
  1935. #endif
  1936.         fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  1937. #else
  1938.         fprintf (stderr, " compiled by CC.\n");
  1939. #endif
  1940.         print_target_switch_defaults ();
  1941.       }
  1942.     else if (!strcmp (str, "w"))
  1943.       inhibit_warnings = 1;
  1944.     else if (!strcmp (str, "W"))
  1945.       extra_warnings = 1;
  1946.     else if (!strcmp (str, "Wunused"))
  1947.       warn_unused = 1;
  1948.     else if (!strcmp (str, "Wshadow"))
  1949.       warn_shadow = 1;
  1950.     else if (!strcmp (str, "Wswitch"))
  1951.       warn_switch = 1;
  1952.     else if (!strncmp (str, "Wid-clash-", 10))
  1953.       {
  1954.         char *endp = str + 10;
  1955.  
  1956.         while (*endp)
  1957.           {
  1958.         if (*endp >= '0' && *endp <= '9')
  1959.           endp++;
  1960.         else
  1961.           error ("Invalid option `%s'", argv[i]);
  1962.           }
  1963.         warn_id_clash = 1;
  1964.         id_clash_len = atoi (str + 10);
  1965.       }
  1966.     else if (!strcmp (str, "p"))
  1967.       profile_flag = 1;
  1968.     else if (!strcmp (str, "a"))
  1969.       {
  1970. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  1971.         warning ("`-a' option (basic block profile) not supported");
  1972. #else
  1973.         profile_block_flag = 1;
  1974. #endif
  1975.       }
  1976.     else if (!strcmp (str, "gg"))
  1977.       write_symbols = GDB_DEBUG;
  1978. #ifdef DBX_DEBUGGING_INFO
  1979.     else if (!strcmp (str, "g0"))
  1980.       write_symbols = DBX_DEBUG;
  1981.     else if (!strcmp (str, "G0"))
  1982.       write_symbols = DBX_DEBUG;
  1983.     else if (!strcmp (str, "g"))
  1984.       {
  1985.         write_symbols = DBX_DEBUG;
  1986.         use_gdb_dbx_extensions = 1;
  1987.       }
  1988.     else if (!strcmp (str, "G"))
  1989.       {
  1990.         write_symbols = DBX_DEBUG;
  1991.         use_gdb_dbx_extensions = 1;
  1992.       }
  1993. #endif
  1994. #ifdef SDB_DEBUGGING_INFO
  1995.     else if (!strcmp (str, "g"))
  1996.       write_symbols = SDB_DEBUG;
  1997.     else if (!strcmp (str, "G"))
  1998.       write_symbols = SDB_DEBUG;
  1999.     else if (!strcmp (str, "g0"))
  2000.       write_symbols = SDB_DEBUG;
  2001.     else if (!strcmp (str, "G0"))
  2002.       write_symbols = SDB_DEBUG;
  2003. #endif
  2004.     else if (!strcmp (str, "symout"))
  2005.       {
  2006.         if (write_symbols == NO_DEBUG)
  2007.           write_symbols = GDB_DEBUG;
  2008.         sym_file_name = argv[++i];
  2009.       }
  2010.     else if (!strcmp (str, "o"))
  2011.       {
  2012.         asm_file_name = argv[++i];
  2013.       }
  2014.     else
  2015.       error ("Invalid option `%s'", argv[i]);
  2016.       }
  2017.     else
  2018.       filename = argv[i];
  2019.  
  2020. #ifdef OVERRIDE_OPTIONS
  2021.   /* Some machines may reject certain combinations of options.  */
  2022.   OVERRIDE_OPTIONS;
  2023. #endif
  2024.  
  2025.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  2026.   init_reg_sets_1 ();
  2027.  
  2028.   compile_file (filename);
  2029.  
  2030. #ifndef USG
  2031. #ifndef VMS
  2032.   if (print_mem_flag)
  2033.     {
  2034.       extern char **environ;
  2035.       char *lim = (char *) sbrk (0);
  2036.  
  2037.       fprintf (stderr, "Data size %d.\n",
  2038.            (int) lim - (int) &environ);
  2039.       fflush (stderr);
  2040.  
  2041.       system ("ps v");
  2042.     }
  2043. #endif /* not VMS */
  2044. #endif /* not USG */
  2045.  
  2046.   if (errorcount)
  2047.     exit (FATAL_EXIT_CODE);
  2048.   if (sorrycount)
  2049.     exit (FATAL_EXIT_CODE);
  2050.   exit (SUCCESS_EXIT_CODE);
  2051.   return 34;
  2052. }
  2053.  
  2054. /* Decode -m switches.  */
  2055.  
  2056. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  2057.    and which bits in `target_switches' it should set or clear.
  2058.    If VALUE is positive, it is bits to set.
  2059.    If VALUE is negative, -VALUE is bits to clear.
  2060.    (The sign bit is not used so there is no confusion.)  */
  2061.  
  2062. struct {char *name; int value;} target_switches []
  2063.   = TARGET_SWITCHES;
  2064.  
  2065. /* Decode the switch -mNAME.  */
  2066.  
  2067. void
  2068. set_target_switch (name)
  2069.      char *name;
  2070. {
  2071.   register int j;
  2072.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2073.     if (!strcmp (target_switches[j].name, name))
  2074.       {
  2075.     if (target_switches[j].value < 0)
  2076.       target_flags &= ~-target_switches[j].value;
  2077.     else
  2078.       target_flags |= target_switches[j].value;
  2079.     return;
  2080.       }
  2081.   error ("Invalid option `%s'", name);
  2082. }
  2083.  
  2084. /* Print default target switches for -version.  */
  2085.  
  2086. void
  2087. print_target_switch_defaults ()
  2088. {
  2089.   register int j;
  2090.   register int mask = TARGET_DEFAULT;
  2091.   fprintf (stderr, "default target switches:");
  2092.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2093.     if (target_switches[j].name[0] != '\0'
  2094.     && target_switches[j].value > 0
  2095.     && (target_switches[j].value & mask) == target_switches[j].value)
  2096.  
  2097.       fprintf (stderr, " -m%s", target_switches[j].name);
  2098.  
  2099.   fprintf (stderr, "\n");
  2100. }
  2101. @
  2102.  
  2103.  
  2104. 1.1
  2105. log
  2106. @Initial revision
  2107. @
  2108. text
  2109. @d1185 6
  2110. a1190 1
  2111.       warning_with_decl (decl, "`%s' defined but not used");
  2112. @
  2113.